﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HT.Model;

namespace HT.Service
{
    public class ReimbursementServiceImpl : IReimbursementService
    {  
        public event EventHandler<ReimbursementEventArgs> ReimbursementSave;
        public event EventHandler<ReimbursementEventArgs> ReimbursementApprove;
        public event EventHandler<ReimbursementEventArgs> ReimbursementReject;
        public event EventHandler<ReimbursementEventArgs> ReimbursementSendBack;        

        public void RaiseSaveEvent(ReimbursementInfo reimbursementInfo)
        {
            if (ReimbursementSave != null)
            {
                ReimbursementEventArgs e = new ReimbursementEventArgs(reimbursementInfo.InstanceID, reimbursementInfo);
                e.WaitForIdle = true;
                ReimbursementSave(null, e);               
            }
        }

        public void RaiseApproveEvent(ReimbursementInfo reimbursementInfo)
        {
            if (ReimbursementApprove != null)
            {
                ReimbursementEventArgs e = new ReimbursementEventArgs(reimbursementInfo.InstanceID, reimbursementInfo);
                e.WaitForIdle = true;
                ReimbursementApprove(null, e);
            }
        }

        public void RaiseRejectEvent(ReimbursementInfo reimbursementInfo)
        {
            if (ReimbursementReject != null)
            {
                ReimbursementEventArgs e = new ReimbursementEventArgs(reimbursementInfo.InstanceID, reimbursementInfo);
                e.WaitForIdle = true;
                ReimbursementReject(null, e);
            }
        }

        public void RaiseSendBackEvent(ReimbursementInfo reimbursementInfo)
        {
            if (ReimbursementSendBack != null)
            {
                ReimbursementEventArgs e = new ReimbursementEventArgs(reimbursementInfo.InstanceID, reimbursementInfo);
                e.WaitForIdle = true;
                ReimbursementSendBack(null, e);
            }
        }

    }  
}
